import {createRequestWithPrefix} from '../axios.js';

const requestTask = (...args) => {
  return createRequestWithPrefix('task')(...args)
    .then(({ data }) => data);
};

async function create({ content, remindTime }) {
  return requestTask('post', '/', { content, remindTime });
}

async function getList(params = {}) {
  return requestTask('get', '/list', params);
}

async function getById(id) {
  return requestTask('get', `/${id}`);
}

async function updateById(id, data) {
  return requestTask('put', `/${id}`, data);
}

async function deleteById(id) {
  return requestTask('delete', `/${id}`);
}

export { create, getList, getById, updateById, deleteById };
